package com.turnengine.client.global.game.command.gwt;

import static com.javabi.common.dependency.DependencyFactory.getDependency;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.javabi.codebuilder.generated.gwt.IGeneratedRemoteServiceServlet;
import com.javabi.command.IExecutableCommandResponse;
import com.javabi.command.errorcode.gwt.GwtErrorCodeException;
import com.javabi.command.executor.ICommandExecutorService;
import com.turnengine.client.global.game.bean.IGameHost;
import com.turnengine.client.global.game.command.GetGameHosts;
import java.util.List;

/**
 * The Get Game Hosts Servlet.
 */
public class GetGameHostsServlet extends RemoteServiceServlet implements IGeneratedRemoteServiceServlet, GetGameHostsService {

	public List<IGameHost> getGameHosts() throws GwtErrorCodeException {
		GetGameHosts command = new GetGameHosts();
		ICommandExecutorService service = getDependency(ICommandExecutorService.class);
		IExecutableCommandResponse<List<IGameHost>> response = service.execute(command);
		if (response.hasErrors()) {
			throw new GwtErrorCodeException(response);
		}
		return response.getReturnValue();
	}
}
